package com.fish.anne.model;

import com.fish.anne.model.BaseObject;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;

import java.io.Serializable;

@Entity
@Table(name="system_admin_session" )
public class SystemAdminSession extends BaseObject implements Serializable {
    private String sessId;
    private Long adminId;
    private Long loginTime;
    private Long lastActionTime;
    private Long apiId;
    private String sessData;
    private byte status;
    private String loginIp;

    @Id  @GeneratedValue(strategy = GenerationType.IDENTITY)    
    public String getSessId() {
        return this.sessId;
    }
    
    public void setSessId(String sessId) {
        this.sessId = sessId;
    }
    
    @Column(name="admin_id", nullable=false)
    public Long getAdminId() {
        return this.adminId;
    }
    
    public void setAdminId(Long adminId) {
        this.adminId = adminId;
    }
    
    @Column(name="login_time", nullable=false)
    public Long getLoginTime() {
        return this.loginTime;
    }
    
    public void setLoginTime(Long loginTime) {
        this.loginTime = loginTime;
    }
    
    @Column(name="last_action_time", nullable=false)
    public Long getLastActionTime() {
        return this.lastActionTime;
    }
    
    public void setLastActionTime(Long lastActionTime) {
        this.lastActionTime = lastActionTime;
    }
    
    @Column(name="api_id", nullable=false)
    public Long getApiId() {
        return this.apiId;
    }
    
    public void setApiId(Long apiId) {
        this.apiId = apiId;
    }
    
    @Column(name="sess_data", nullable=false)
    public String getSessData() {
        return this.sessData;
    }
    
    public void setSessData(String sessData) {
        this.sessData = sessData;
    }
    
    @Column(name="status", nullable=false)
    public byte getStatus() {
        return this.status;
    }
    
    public void setStatus(byte status) {
        this.status = status;
    }
    
    @Column(name="login_ip", nullable=false, length=15)
    public String getLoginIp() {
        return this.loginIp;
    }
    
    public void setLoginIp(String loginIp) {
        this.loginIp = loginIp;
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        SystemAdminSession pojo = (SystemAdminSession) o;

        if (adminId != null ? !adminId.equals(pojo.adminId) : pojo.adminId != null) return false;
        if (loginTime != null ? !loginTime.equals(pojo.loginTime) : pojo.loginTime != null) return false;
        if (lastActionTime != null ? !lastActionTime.equals(pojo.lastActionTime) : pojo.lastActionTime != null) return false;
        if (apiId != null ? !apiId.equals(pojo.apiId) : pojo.apiId != null) return false;
        if (sessData != null ? !sessData.equals(pojo.sessData) : pojo.sessData != null) return false;
         if (loginIp != null ? !loginIp.equals(pojo.loginIp) : pojo.loginIp != null) return false;

        return true;
    }

    public int hashCode() {
        int result = 0;
        result = (adminId != null ? adminId.hashCode() : 0);
        result = 31 * result + (loginTime != null ? loginTime.hashCode() : 0);
        result = 31 * result + (lastActionTime != null ? lastActionTime.hashCode() : 0);
        result = 31 * result + (apiId != null ? apiId.hashCode() : 0);
        result = 31 * result + (sessData != null ? sessData.hashCode() : 0);
         result = 31 * result + (loginIp != null ? loginIp.hashCode() : 0);

        return result;
    }

    public String toString() {
        StringBuffer sb = new StringBuffer(getClass().getSimpleName());

        sb.append(" [");
        sb.append("sessId").append("='").append(getSessId()).append("', ");
        sb.append("adminId").append("='").append(getAdminId()).append("', ");
        sb.append("loginTime").append("='").append(getLoginTime()).append("', ");
        sb.append("lastActionTime").append("='").append(getLastActionTime()).append("', ");
        sb.append("apiId").append("='").append(getApiId()).append("', ");
        sb.append("sessData").append("='").append(getSessData()).append("', ");
        sb.append("status").append("='").append(getStatus()).append("', ");
        sb.append("loginIp").append("='").append(getLoginIp()).append("'");
        sb.append("]");
      
        return sb.toString();
    }

}
